package com.yangye.otherdemo.netty;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.CharsetUtil;

public class MyInHandler extends ChannelInboundHandlerAdapter {

	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
		ByteBuf buf = (ByteBuf) msg;
		CharSequence s = buf.getCharSequence(0, buf.readableBytes(), CharsetUtil.UTF_8);
		System.out.println("收到消息： " + s);
		ctx.channel().writeAndFlush(buf);
	}
}
